<template>
  <div>
    <h1>vue3新增watchEffect</h1>
    <h2>和：{{sum}}</h2>
    <button @click="sum++">+</button>
  </div>
</template>

<script>
import {ref,reactive,watch,watchEffect} from 'vue'
export default {
  setup () {
    let sum =ref(0)
    let person = reactive({
      name:'续航三',
      age:18
    })

    watch(sum,(newval)=>{
      console.log(newval)
    })


    watchEffect(()=>{
      const x1 = sum.value
      console.log('回调执行了',x1)
    })



    return {
      sum,
      person
    }
  }
}
</script>

<style lang="scss" scoped>

</style>